package com.book.demo.Mapper;

import com.book.demo.Pojo.Gonggao;
import com.book.demo.Pojo.Wenda;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface GonggaoMapper {
    // 获取前4条公告，最近时间的公告排在前面
    @Select("select * from gonggao order by time desc limit 4")
    List<Gonggao> getGonggaotop4();

    // 通过id获取公告
    @Select("select * from gonggao where id = #{id}")
    Gonggao getGonggaoById(int id);

    //统计公告总数
    @Select("select count(*) from gonggao")
    int getGonggaoCount();

    // 管理员添加公告
    @Insert("insert into gonggao(`user`,title,content,expirationtime,important,html) values(#{user},#{title},#{content},#{expirationtime},#{important},#{html})")
    int AdminAddGonggao(Gonggao gonggao);

    // 删除公告
    @Delete("delete from gonggao where id = #{id}")
    int deleteGonggao(int id);

   // 查询公告的动态查询
   // 分页查询问答记录gettype:notexpired、expired表示查询未过期的公告还是已过期的公告;
   // pageNum表示限制查询的个数，-1为查询所有
   List<Gonggao> DongTaiGetGonggao(@Param("limitNum") int limitNum,
                               @Param("selecttype") String selecttype);
}
